import requests
import json
from urllib3.exceptions import InsecureRequestWarning
import datetime

# 禁用安全请求警告
Platform = "微阅云"
today = datetime.date.today()  # 今天
yester = today - datetime.timedelta(days=1)


def weiyueyun():
    try:
        requests.urllib3.disable_warnings(InsecureRequestWarning)
        r = requests.session()
        url = "https://ag.emeixs.com/login/in.html"
        date = {
            "username": "",
            "password": "",
        }
        rr = r.post(url=url, data=date, verify=False, timeout=15)
        aa = r.get(url="https://ag.emeixs.com/main/daily.html?list_rows=20&page=1", verify=False, timeout=15)
        html = json.loads(aa.text)
        for y in range(len(html["rows"])):
            if str(html["rows"][y]["sumon"]) == str(yester):
                Amount_share = html["rows"][y]["total_money"]
                Amount_share = round(int(Amount_share) * 0.9, 2)
                date_time = str(yester)
                return date_time, Amount_share, Platform
            else:
                if y == len(html["rows"]) - 1:
                    return '', 'None', Platform
                else:
                    pass
    except Exception:
        print("获取 微阅云 数据失败")
        return '', 'None', Platform
    except ConnectionError:
        print("获取 微阅云 数据 超时")
        return '', 'None', Platform
